<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hz.util.ParamUtil"%>
<%@page import="com.hz.model.Activity"%>
<%@page import="com.hz.control.ActivityControl"%>
<%@page import="com.hz.control.ActTypeControl"%>
<%@page import="com.hz.model.ActType"%>
<%@page import="com.hz.model.ParamDepartment"%>
<%@page import="com.hz.control.ParamDepartmentManager"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  <link rel="stylesheet" href="../../../kindeditor/themes/default/default.css" />
	<link rel="stylesheet" href="../../../kindeditor/plugins/code/prettify.css" />
	<link rel="stylesheet" type="text/css" href="../../../css/active.css"/>
	<script charset="utf-8" src="../../../kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="../../../kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="../../../kindeditor/plugins/code/prettify.js"></script>
	<script type="text/javascript" src="../../common/js/WebCalendar.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content1"]', {
				cssPath : '../../../kindeditor/plugins/code/prettify.css',
				uploadJson : '../../../kindeditor/jsp/upload_json.jsp',
				fileManagerJson : '../../../kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
  <body>
  <%
      request.setCharacterEncoding("utf-8");
      String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
      int acid = ParamUtil.getInt(request,"acid");
      Activity a = ActivityControl.getActivityInformation(acid);
   %>
   <form action="activity_update_do.jsp?acid=<%=acid %>" method="post">
  <table class='add' style="width:500px;">
  <tr><td width='80'>活动名称</td><td width='140'><input type="text" name="actName" value="<%=a.getActName() %>"/></td>
  <td width='80'>活动类型</td><td width='140'><select name="actType">
  <%
       Collection<ActType> atps = ActTypeControl.getAllActTypes();
       Iterator<ActType> it = atps.iterator();
       while(it.hasNext()){
       ActType at =  it.next();
   %>
   <option value="<%=at.getId() %>" <%if(at.getId()==a.getActType()) out.print("selected='selected'"); %>><%=at.getTypeName() %></option>
   <%} %>
  </select></td>
  </tr>
  
  <tr><td>开始时间</td><td><input type="text" name="startTime" value="<%=a.getStartTime() %>" maxlength="100" id="Text3"  onclick="SelectDate(this,'yyyy-MM-dd hh:mm')" readonly style="width:140px;cursor:pointer"/></td>
  <td>结束时间</td><td><input type="text" name="endTime" value="<%=a.getEndTime() %>" maxlength="100" id="Text3"  onclick="SelectDate(this,'yyyy-MM-dd hh:mm')" readonly  style="width:140px;cursor:pointer"/></td>
</tr>
  <tr>  <td>活动地点</td><td><input type="text" name="place" value="<%=a.getPlace() %>"/></td>
    <td >活动人数</td><td><input type="text" name="peopleNum" value="<%=a.getPeopleNum() %>"/></td></tr>
  <tr><td>活动花费</td><td><input type="text" name="cost" value="<%=a.getCost() %>"/></td>
  <td>所用资源</td><td><input type="text"  name="resource" value="<%=a.getResource() %>"/></td>
  </tr>
  <tr>
  <td>花费明细</td><td colspan="3"><textarea style='width:100%;' name="costDetail"/> <%=a.getCostDetail() %></textarea></td>
  </tr>
  
  <tr><td>负责人</td><td><input type="text" name="leader" value="<%=a.getLeader() %>"/></td>
  <td>举办学院</td><td><select name="departmentId" id="departmentId">
<% 
    ArrayList<ParamDepartment> pd = ParamDepartmentManager.getAllDepartment(0);
    for(int i=0;i<pd.size();i++){
        ParamDepartment p = pd.get(i);  
 %>
<option value="<%=p.getId() %>" <%if(p.getId()==a.getDepartmentId()) out.print("selected='selected'"); %>><%=p.getDepartmentName() %></option>
<%} %>
</select></td></tr>
 <tr>
	    <td colspan="4"><%=htmlData%>
	
		<textarea name="content1" cols="100" rows="8" style="width:498px;height:300px;visibility:hidden;"><%=htmlspecialchars(htmlData)%><%out.println(a.getContent());%></textarea>
		<br /></td>
	</tr>
<tr>
<td colspan='2'><input type="submit" value="提交"/></td>
<td colspan='2'><input type="reset" value="重置"/></td>
</tr>
  </table>
  </form>
  </body>
</html>
<%!
private String htmlspecialchars(String str) {
	str = str.replaceAll("&", "&amp;");
	str = str.replaceAll("<", "&lt;");
	str = str.replaceAll(">", "&gt;");
	str = str.replaceAll("\"", "&quot;");
	return str;
}
%>